# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-rubytest
pkgver=0.8.1
# https://github.com/rubyworks/rubytest/issues/7
_commit=39e02662650f2954a7ae7198ac5ea2dc5a7410ce
pkgrel=1
pkgdesc='Core API for Ruby Universal Test Harness'
arch=(any)
url='https://github.com/rubyworks/rubytest'
license=(BSD)
depends=(ruby)
checkdepends=(ruby-ae ruby-qed)
options=(!emptydirs)
source=(https://github.com/rubyworks/rubytest/archive/$_commit/$pkgname-$_commit.tar.gz)
sha256sums=('58130e9c6c9f7c5bb0659fdf385743bb6741233a95bed574a22f499fddca7667')

build() {
  local _gemdir="$(gem env gemdir)"
  cd rubytest-$_commit
  gem build .gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    rubytest-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd rubytest-$_commit
  GEM_HOME="tmp_install/$_gemdir" qed -Ilib
}

package() {
  cd rubytest-$_commit
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
